CC=gcc

ROOT=.
PROJDIR=$(ROOT)/../../..
OBJDIR=$(PROJDIR)/obj
SRCDIR=$(ROOT)


SRCS=$(wildcard $(SRCDIR)/*.c)
tmps=$(notdir $(SRCS))
OBJS=$(patsubst %.c,$(ROOT)/%.o,$(tmps))
TARGET=$(OBJDIR)/libpit.a

INCS=-I$(PROJDIR)/include -I$(PROJDIR)/include/driver
CFLAGS=$(INCS) -Wall -Wextra -Werror -mcmodel=large -fno-builtin -m64 -nostdlib -nolibc -nostdinc -fno-stack-protector -nostartfiles -nodefaultlibs -ffreestanding

ifeq ($(DEBUG),ON)
CFLAGS+=-g3
endif

.PHONY: all clean 

all:$(TARGET)

test:
	echo $(SRCS)

$(TARGET):$(OBJS)
	ar rc $@ $^


%.o:%.c
	gcc -c $(CFLAGS) -o $@ $<

clean:
	rm -f $(OBJS) $(TARGET)
